﻿using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using Silent.WCF.Interfaces;

namespace Silent.WCF.Base
{
    public abstract class ServiceManagerBase : IService
    {
        private readonly List<IService> m_services;

        protected ServiceManagerBase()
        {
            m_services = new List<IService>();
        }

        public ServiceHost Host { get; set; }

        public abstract void Initialize();

        public void AddService<T>(T service) where T : class, IService
        {
            m_services.Add(service);
        }
        public T GetService<T>() where T : class, IService
        {
            return m_services.FirstOrDefault(x => x is T) as T;
        }
    }
}